package com.test.ml.yqs.web;


import com.test.ml.yqs.entity.User;
import com.test.ml.yqs.entity.UserTask;
import com.test.ml.yqs.service.UserTaskService;
import com.test.ml.yqs.utills.ResultJson;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author 马亮
 * @version V1.0
 * @Description: TODO
 */
@RestController
@RequestMapping("yqs/userTask")
public class UserTaskController {
    @Autowired
    private UserTaskService service;

    /**
     * 创建自己的任务
     * @param userTask
     * @return
     */
    @RequestMapping("addTask")
    public ResultJson AddUserTask(@RequestBody UserTask userTask){
        Subject sub=  SecurityUtils.getSubject();
         User user= (User) sub.getPrincipal();
        userTask.setUserId(user.getId());
        service.AddTask(userTask);
        return ResultJson.buildSuccess("新建成功");
    }

}